<?php
require_once 'BasicController.php';

class MessageController extends BasicController
{

	public function init()
	{
		$ad = new AdminBusiness();
		$user = Zend_Auth::getInstance()->getStorage()->read();
		$this->view->user = $user;

		if(isset($user) && $user != null){
			$cartBusiness = new CartBusiness();
			$this->view->shopping_count = $cartBusiness->countItems($user['idClient']);
		}
		
		$this->view->enterprises = $ad->getAllEnterprises();
		$this->view->categories = $ad->getAllCategories();
	}
	
	public function indexAction()
	{
		
	}
	
	public function sendCommentAction(){
		
		if($_POST){
			
			$messageBusiness = new MessageBusiness();
			
			$data = array(
				"id_product" => $this->getRequest()->getParam ("comment-product"),
				"id_client" => $this->getRequest()->getParam ("comment-client"),
				"comment" => $this->getRequest()->getParam ("comment"),
				"date" => date("Y-m-d H:i:s"),
			);
			
			$messageBusiness->sendComment($data);
		}
		
	}

}

